package org.aspire.data.renderer;

import org.aspire.core.sys.GameException;
import org.aspire.data.Owner;
import org.aspire.data.Renderer;
import org.aspire.graphics.Color;
import org.aspire.graphics.DrawGraphics;
import org.aspire.graphics.Frame;
import org.aspire.graphics.draw.JavaStandardGraphics;

/******************************************************************************
 * A renderer implementation for the Java Standard Edition (J2SE). It uses
 * hardware-accelerated graphics and audio clip for rendering graphical and
 * audio data.
 * 
 * @author JPACarabuena
 *****************************************************************************/
public class JavaStandardRenderer implements Renderer {

	// ========================================================================
	// Constants
	// ========================================================================

	// ========================================================================
	// Static Method
	// ========================================================================

	// ========================================================================
	// Fields
	// ========================================================================
	
	/**************************************************************************
	 * The owner of this java standard renderer.
	 *************************************************************************/
	private Owner owner;
	
	/**************************************************************************
	 * The graphics renderer.
	 *************************************************************************/
	private JavaStandardGraphics graphics;

	// ========================================================================
	// Constructors
	// ========================================================================

	// ========================================================================
	// Getters & Setters
	// ========================================================================

	// ========================================================================
	// Override Methods
	// ========================================================================

	@Override
	public Owner getOwner() {
		return this.owner;
	}

	@Override
	public DrawGraphics getGraphicsRenderer() {
		return this.graphics;
	}

	@Override
	public Object getAudioRenderer() {
		return null;
	}

	@Override
	public void setOwner(Owner owner) {
		this.owner = owner;
	}

	@Override
	public void setGraphicsRenderer(DrawGraphics graphics) {
		if(graphics instanceof JavaStandardGraphics) {
			this.graphics = (JavaStandardGraphics) graphics;
		}
	}
	
	@Override
	public void setColor(Color color) {
		this.graphics.setColor(color);
	}

	@Override
	public void setAudioRenderer(Object object) {
		
	}

	@Override
	public void drawLine(int x1, int y1, int x2, int y2) {
		this.graphics.drawLine(x1, y1, x2, y2);
	}

	@Override
	public void drawRect(int x, int y, int width, int height) {
		this.graphics.drawRect(x, y, width, height);
	}

	@Override
	public void fillRect(int x, int y, int width, int height) {
		this.graphics.fillRect(x, y, width, height);
	}

	@Override
	public void drawOval(int x, int y, int width, int height) {
		this.graphics.drawOval(x, y, width, height);
	}

	@Override
	public void fillOval(int x, int y, int width, int height) {
		this.graphics.fillOval(x, y, width, height);
	}

	@Override
	public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
			throws GameException {
		this.graphics.drawPolygon(xPoints, yPoints, nPoints);
	}

	@Override
	public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
			throws GameException {
		this.graphics.fillPolygon(xPoints, yPoints, nPoints);
	}

	@Override
	public void drawString(String str, int x, int y) {
		this.graphics.drawString(str, x, y);
	}

	@Override
	public void drawImage(Frame image, int x, int y) {
		this.graphics.drawImage(image, x, y);
	}

	@Override
	public void playMusic(String str) {
		
	}

	@Override
	public void playSound(String str) {
		
	}

	// ========================================================================
	// Methods
	// ========================================================================

	// ========================================================================
	// Inner & Anonymous Classes
	// ========================================================================
}